﻿using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Write.Applications.Commands.ReportCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Packaged.WebAPI.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReportController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReportController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加报工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CreateReport(CreateReportCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除报工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelReport(DelReportCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改报工表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdReport(UpdReportCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
